﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _2
{
    internal class CreditAccount : Account
    {
        public decimal CreditLimit { get; private set; }

        public CreditAccount(string accountNumber, decimal initialBalance, decimal creditLimit)
            : base(accountNumber, initialBalance)
        {
            CreditLimit = creditLimit;
        }

        public override decimal Withdraw(decimal amount)
        {
            if (Balance + CreditLimit < amount)
                throw new InvalidOperationException("超过信用额度");
            Balance -= amount;
            return amount;
        }
    }
}
